package com.px.controller;

import com.px.mapper.ShCommodityTempStockMapper;
import com.px.pojo.ShCommodityTempStock;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ProviderShCommodityTempStockController {

    @Resource
    private ShCommodityTempStockMapper shCommodityTempStockMapper;

    @PostMapping("/api/provider/selectShCommodityTempStockList")
    public List<ShCommodityTempStock> selectShCommodityTempStockList(@RequestParam String commodityName,
                                                   @RequestParam Integer dicOneId,
                                                   @RequestParam Integer dicTwoId,
                                                   @RequestParam Double minPrice,
                                                   @RequestParam Double maxPrice,
                                                   @RequestParam String ram,
                                                   @RequestParam Integer pageBegin,
                                                   @RequestParam Integer pageSize)throws Exception{
        List<ShCommodityTempStock> shCommodityTempStocks = shCommodityTempStockMapper.selectShCommodityTempStockStatus(commodityName, dicOneId, dicTwoId, minPrice, maxPrice, ram, pageBegin, pageSize);
        if("".equals(shCommodityTempStocks) && null == shCommodityTempStocks){
            return null;
        }
        return shCommodityTempStocks;
    }

    @PostMapping("/api/provider/selectShCommodityTempStockCount")
    public Integer selectShCommodityTempStockCount(@RequestParam String commodityName,
                                          @RequestParam Integer dicOneId,
                                          @RequestParam Integer dicTwoId,
                                          @RequestParam Double minPrice,
                                          @RequestParam Double maxPrice,
                                          @RequestParam String ram)throws Exception{
        int count = shCommodityTempStockMapper.selectShCommodityTempStockCount(commodityName, dicOneId,dicTwoId,minPrice,maxPrice,ram);
        if (count > 0) {
            return count;
        }
        return 0;
    }


}
